﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace can.Model
{
    class PLCInfo
    {
        public string IP { get; set; } = "192.168.0.88";

        public int Port { get; set; } = 502;

        public string COM { get; set; } = "COM1";

        public PLCType Type { get; set; } = PLCType.TCP;

        public ushort ReadHeartBeat { get; set; } = 500;

        public ushort[] BIBFanOutputTempWarning { get; set; } = { 2, 3, 4, 5, 6, 7 };

        public ushort[] ControlFanOutputTempWarning { get; set; } = { 8, 9, 10, 11, 12, 13 };

        public ushort[] BIBFanOutputTemp { get; set; } = { 524,525,526,527,528,529 };

        public ushort[] ControlFanOutputTemp { get; set; } = { 530,531,532,533,534,535 };

        public ushort[] BIBFanOutputSpeed { get; set; } = { 550, 551, 552, 553, 554, 555 };

        public ushort[] BIBFanInPutSpeed { get; set; } = { 556, 557, 558, 559, 560, 561 };

        public ushort[] ControlFanSpeed { get; set; } = { 562, 563, 564, 565, 566, 567 };

        public ushort WaterInletTemp { get; set; } = 570;

        public ushort WaterOutletTemp { get; set; } = 572;

        public ushort WaterInletPressure { get; set; } = 574;

        public ushort WaterOutletPressure { get; set; } = 576;

        public ushort ColdWaterFlow { get; set; } = 578;

        public ushort EnableHeart { get; set; } = 609;

        public ushort WriteHeartBeat { get; set; } = 600;

        public ushort[] WriteFanEnable { get; set; } = { 601, 602, 603, 604, 605, 606 };

        public ushort[] WriteBIBFanOutputGear { get; set; } = { 300, 301, 302, 303, 304, 305 };

        public ushort[] WriteBIBFanInputGear { get; set; } = { 306, 307, 308, 309, 310, 311 };

        public ReadOnlyDictionary<int, ushort> ErrorCode2Alarm = new ReadOnlyDictionary<
            int,
            ushort
        >(
            new Dictionary<int, ushort>()
            {
                { 1003, 100 },
                { 1004, 101 },
                { 2000, 102 },
                { 2001, 103 },
                { 2002, 104 },
                { 2003, 105 },
                { 2004, 106 },
                { 2005, 107 },
                { 2006, 108 },
                { 2007, 109 },
                { 2008, 110 },
                { 2009, 111 },
                { 2010, 112 },
                { 2011, 113 },
                { 2012, 114 },
                { 2013, 115 },
                { 2014, 116 },
                { 2015, 117 },
                { 3000, 118 },
                { 3001, 119 },
                { 3002, 120 },
                { 3003, 121 },
                { 3004, 122 },
                { 3005, 123 },
                { 3006, 124 }
            }
        );
    }

    public enum PLCType
    {
        COM,
        TCP
    }
}
